package com.mo;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.net.URL;
import java.util.Objects;

/**
 * @author 墨渐生微
 * @program mo-all
 * @apiNote
 * @since 2023/2/17
 */
public class SpiderDemo {


    public static void main(String[] args) {
        try {
            Document document = Jsoup.parse(new URL("https://baike.baidu.com/item/孙悟空/5576"), 2000);

            Elements elements = document.body().select(".basicInfo-item.name");
            for (Element name : elements) {
                Element value = name.nextElementSibling();
                System.out.println(name.text() + "\t" + Objects.requireNonNull(value).text());
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
